package cn.tedu.xuecha.infrastructure.data.converter;

import cn.tedu.xuecha.common.ex.ServiceException;
import cn.tedu.xuecha.common.pojo.Content;
import cn.tedu.xuecha.common.respone.AppCode;
import cn.tedu.xuecha.protocol.param.ContentDTO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;

/**
 * @author coinyang
 * @date 2023/5/4 14:45
 */
@Component
public class ContentConverter {

    public Content toContent(ContentDTO contentDTO){
        if(contentDTO == null){
            throw   new ServiceException(AppCode.ERR_CONFLICT,"文件不能为空");
        }
        Content content = new Content();
        BeanUtils.copyProperties(contentDTO,content);
        return content;
    }
}
